﻿//-----------------------------------------------------------------------
// <copyright file="DanceInitializer.cs" company="Christian Coda">
// Copyright (c) Christian Coda. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DancingSite.Models
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity;

    /// <summary>
    /// Class to Re-init the dance database when the model changes.
    /// TODO: remove for production code.
    /// </summary>
    public class DanceInitializer : DropCreateDatabaseIfModelChanges<DanceDBContext>
    {
        /// <summary>
        /// Seed the database with some dummy events.
        /// </summary>
        /// <param name="context">The database context.</param>
        protected override void Seed(DanceDBContext context)
        {
            var dances = new List<Dance> 
            {      
                new Dance 
                { 
                    Title = "Noches De Salsa",
                    Genre = new DanceGenre { Name = "Salsa" },
                    Category = new EventCategory { EventType = "Class" },
                    Schedules = new List<Schedule>
                    {
                        new Schedule
                        {
                            StartTime = DateTime.Parse("Thu, 06 December 2012 20:00:00"),
                            EndTime = DateTime.Parse("Thu, 06 December 2012 23:00:00")
                        },

                        new Schedule
                        {
                            StartTime = DateTime.Parse("Thu, 13 December 2012 20:00:00"),
                            EndTime = DateTime.Parse("Thu, 13 December 2012 23:00:00")
                        }
                    },

                    Location = new Location
                    {
                        Address1 = "Co-op Sport and Social Club",
                        Address2 = "Preston New Rd Blackpool",
                        PostCode = "FY1 2AB",
                        TownCity = "Blackpool",
                        Region = "North West"
                    },

                    Description = "Weekly salsa class",
                    Price = 5.00M 
                },

                new Dance 
                { 
                    Title = "Salsology Christmas Party",
                    Genre = new DanceGenre { Name = "Salsa" },
                    Category = new EventCategory { EventType = "Party" },
                    Schedules = new List<Schedule>
                    {
                        new Schedule
                        {
                            StartTime = DateTime.Parse("Fri, 07 December 2012 20:00:00"),
                            EndTime = DateTime.Parse("Fri, 07 December 2012 23:00:00")
                        }
                    },

                    Location = new Location
                    {
                        Address1 = "Longfield Suite",
                        Address2 = "Bury Rd",
                        PostCode = "M1 1AB",
                        TownCity = "Manchester",
                        Region = "North West"
                    },

                    Description = "Christmas party at salsology",
                    Price = 8.00M 
                },

                new Dance 
                { 
                    Title = "Tower Inferno",
                    Genre = new DanceGenre { Name = "Salsa" },
                    Category = new EventCategory { EventType = "Party" },
                    Schedules = new List<Schedule>
                    {
                        new Schedule
                        {
                            StartTime = DateTime.Parse("Fri, 14 December 2012 20:00:00"),
                            EndTime = DateTime.Parse("Fri, 14 December 2012 23:00:00")
                        }
                    },

                    Location = new Location
                    {
                        Address1 = "Blackpool Tower",
                        Address2 = "Promenade",
                        PostCode = "FY8 2AB",
                        TownCity = "Blackpool",
                        Region = "North West"
                    },

                    Description = "Tower party night",
                    Price = 15.00M 
                }
             };

            dances.ForEach(d => context.Dances.Add(d));
        }
    }
}